package com.nikkerball.apps.darkhorse.model.base;

import com.nikkerball.apps.darkhorse.model.change.ChangeEvent;
import com.nikkerball.apps.darkhorse.model.change.ChangeValue;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.List;

/**
 * Represents a person
 *
 * @author marius (created on 2010-11-28)
 */
@MappedSuperclass
public class Person extends NameObject {

    // ----- instance fields -----

    private String surname;

    // ----- constructors -----

    public Person() {
        super();
    }

    public Person(String name, String surname) {
        super(name);
        this.surname = surname;
    }

    // ----- public methods -----

    @Transient
    public List<ChangeValue> getChangeValues(ChangeEvent changeEvent) {
        List<ChangeValue> changeValues = super.getChangeValues(changeEvent);
        changeValues.add(new ChangeValue("surname", getSurname(), changeEvent));
        return changeValues;
    }

    @Column(length = NAME_COLUMN_SIZE, nullable = false)
    public String getSurname() {
        return this.surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

}
